<?php
session_start();
require_once './config/config.php';
require_once './lib/http/HTTP.php';
require_once './lib/smarty/libs/Smarty.class.php';
require_once './app/controller/controller_werkzeug.php';
require_once './app/controller/controller_auth.php';
require_once './app/controller/controller_bewerten.php';
require_once './app/model/model_dbhandler.php';




$smarty = new Smarty;
$contr_werk = new Werkzeug ($smarty);
$contr_bewerten = new Bewerten(_werkzeug_);
$smarty -> template_dir = './app/view/werkzeug';
$smarty -> compile_dir = './lib/smarty/templates_c/werkzeug';
$smarty -> config_dir = './lib/smarty/configs/';
$smarty -> cache_dir = './lib/smarty/cache/';

if (isset($_REQUEST["ladeWerkzeugArt"])) {
	$contr_werk -> loadArtOverview(_werkzeug_);
	die;
}

if (isset($_REQUEST["ladeWerkzeugKategorie"])) {
	$contr_werk -> ladeKategorieOverview(_werkzeug_);
	die;
}

if (isset($_REQUEST["ladeWerkzeugKriterien"])) {
	$contr_werk -> ladeKriterienOverview($_REQUEST["id"],_werkzeug_);
	die;
}

if (isset($_REQUEST["speicherNeueKategorie"])) {
	$contr_werk -> speicherKategorie($_REQUEST["value"], $_REQUEST["art_id"]);
	die;
}

if (isset($_REQUEST["changeWeightKriterium"])) {
	$contr_werk -> changeKriteriumWeight($_REQUEST["id"], $_REQUEST["value"]);
	die;
}

if (isset($_REQUEST["deleteKriterium"])) {
	$contr_werk -> deleteKriterium($_REQUEST["id"], $_REQUEST["art_id"]);
	die;
}

if (isset($_REQUEST["speicherNeueKriterien"])) {
	$contr_werk -> speicherKriterium($_REQUEST["value"], $_REQUEST["art_id"],_werkzeug_);
	die;
}

if (isset($_REQUEST["speicherNeueWerkzeug"])) {
	$contr_werk -> speicherArt($_REQUEST["value"], _werkzeug_);
	die;
}

if (isset($_REQUEST["deleteArt"])) {
	$contr_werk -> deleteWerkzeug ($_REQUEST["id"]);
	die;
}

if (isset($_REQUEST["deleteKategorie"])) {
	$contr_werk -> deleteKategorie ($_REQUEST["id"], $_REQUEST["art_id"]);
	die;
}

if (isset($_REQUEST["addComment"])) {
	$smarty -> assign ('content', $contr_werk -> ladeComment($_REQUEST["id"]));
	$smarty -> display ('addComment.tpl');
	die;
}

if (isset($_REQUEST["saveComment"])) {
	$contr_werk -> saveComment($_REQUEST["id"], $_REQUEST["comment"]);
	die;
}


if (isset($_REQUEST["changeWeightKategorie"])) {
	$contr_werk -> changeKategorieWeight($_REQUEST["id"], $_REQUEST["value"]);
	die;
}
/////

if (isset($_REQUEST["bewerten"])) {
	$smarty -> assign ('data',$contr_bewerten -> ladeBewertung($_REQUEST["id"]));
	$smarty -> assign ("art_id", $_REQUEST["id"]);
	$smarty -> assign ('js', '<script type="text/javascript" src="public/javascript/werkzeug/werkzeug_bewerten.js"></script><script type="text/javascript" src="public/javascript/changeVote.js"></script>');
	$smarty -> assign ('css', '<link rel="stylesheet" type="text/css" href="public/css/ext.css" />');
	$smarty -> display('../master/head.tpl');
	$smarty -> display('werkzeug_bewerten.tpl');
	$smarty -> display('../master/foot.tpl');
	die;
}

if (isset($_REQUEST["speicherPunkte"])) {
	$contr_bewerten -> speicherPunkte($_REQUEST["id"], $_REQUEST["value"]);
	die;
}
if (isset($_REQUEST["addCommentPunkte"])) {
	$smarty -> assign ('content' , $contr_bewerten -> ladeKommentarPunkte($_REQUEST["id"]));
	$smarty -> display('addCommentPunkte.tpl');
	die;
}

if (isset($_REQUEST["saveCommentPunkte"])) {
	$contr_bewerten -> speicherKommentarPunkte($_REQUEST["id"], $_REQUEST["comment"]);
	die;
}

//////
if (isset($_REQUEST["viewKriterien"])) {
	$smarty -> assign ("art_id", $_REQUEST["id"]);
	$smarty -> assign ('js', '<script type="text/javascript" src="public/javascript/werkzeug/werkzeug_kriterien.js"></script><script type="text/javascript" src="public/javascript/werkzeug/change_werkzeug_kategorie_weight.js"></script>');
	$smarty -> assign ('css', '<link rel="stylesheet" type="text/css" href="public/css/ext.css" />');
	$smarty -> display('../master/head.tpl');
	$smarty -> display('werkzeug_kriterien.tpl');
	$smarty -> display('../master/foot.tpl');
	die;
}

if (isset($_REQUEST["viewKategorie"])) {
	$smarty -> assign ("art_id", $_REQUEST["id"]);
	$smarty -> assign ('js', '<script type="text/javascript" src="public/javascript/werkzeug/werkzeug_kategorie.js"></script><script type="text/javascript" src="public/javascript/werkzeug/change_werkzeug_kategorie_weight.js"></script>');
	$smarty -> assign ('css', '<link rel="stylesheet" type="text/css" href="public/css/ext.css" />');
	$smarty -> display('../master/head.tpl');
	$smarty -> display('werkzeug_kategorie.tpl');
	$smarty -> display('../master/foot.tpl');
	die;
}


$smarty -> assign ('js', '<script type="text/javascript" src="public/javascript/werkzeug/werkzeug_art.js"></script>');
$smarty -> assign ('css', '<link rel="stylesheet" type="text/css" href="public/css/ext.css" />');
$smarty -> display('../master/head.tpl');
$smarty -> display('werkzeug_uebersicht.tpl');
$smarty -> display('../master/foot.tpl');
?>